<?php
namespace Plu\Library\Models\Tga\Lottery;

use Phalcon\Mvc\Model,
    Phalcon\Db\Column;

class Applicants extends Model {

    public $id;
    public $uid;
    public $appkey;
    public $signupinfo;
    public $signdate;
    public $status;

    public function initialize() {
        $this->setConnectionService('db.tga');
        //$this->allowEmptyStringValues(array());
    }

    public function getSource() {
        return 'log_lottery';
    }

    static public function getItemByUid($appkey, $uid, $id, $prize_level) {
        $item = self::findFirst(array(
            "appkey = :appkey: AND uid = :uid: AND id = :id: AND prize_level != :prize_level:",
            "bind" => array(
                'appkey' => $appkey,
                'uid'    => $uid,
                'id'     => $id,
                'prize_level' => $prize_level
            ),
            "bindTypes" => array(
                'appkey' => Column::BIND_PARAM_STR,
                'uid'    => Column::BIND_PARAM_INT,
                'id'    => Column::BIND_PARAM_INT,
                'prize_level'    => Column::BIND_PARAM_INT,
            )
        ));

        if ($item == false) {
            return [];
        } else {
            return $item->toArray();
        }
    }
}
?>
